﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="module.aspx.cs" Inherits="UI.system.page.config.module" %>
<%@ Import Namespace="Model" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script src="/js/jquery.min.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/md5.js"></script>
    <script src="/js/swfupload.js"></script>
    <script src="/system/js/admin.js"></script>
    <script src="/system/layui/layui.js"></script>
    <link rel="stylesheet" href="/system/layui/css/layui.css">
    <link rel="stylesheet" href="/system/layui/css/global.css">
    <link rel="stylesheet" href="/system/css/iframe.css">
    <script type="text/javascript" src="/system/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="/system/ueditor/ueditor.all.min.js"> </script>
    <script type="text/javascript" src="/system/ueditor/lang/zh-cn/zh-cn.js"></script>
    <style>
        .name{margin-left:0px;}
        .layui-input{height:30px; line-height:30px;}
        .layui-table td, .layui-table th{padding:5px 5px}
        .layui-form-switch{margin-top:0px;}
        .title{ height:40px; font-size:24px; color:#4f8bed; font-weight:bold; float:left;}
        .upload_show,.upload_product{margin-top:2px;}
    </style>
</head>
<body>
<div style="margin: 35px; margin-top:10px; padding-bottom:35px;">
<form class="layui-form" style="padding-left:0px;">
    <div class="title">首页模块显示设置</div>
    <table class="layui-table">
      <colgroup>
        <col width="200">
        <col width="200">
        <col width="150">
        <col>
        <col width="130">
      </colgroup>
      <thead>
        <tr>
          <th>模块名称</th>
          <th>显示顺序</th>
          <th>显示数量</th>
          <th></th>
          <th>是否显示</th>
        </tr>
      </thead>
      <tbody>
        <tr column="news">
          <td><input type="text" value="<%=news[3] %>" class="layui-input name" onblur="Update_News(this)" disabled="disabled" /></td>
          <td><input type="text" value="<%=news[0] %>" class="layui-input sort" onblur="Update_News(this)"/></td>
          <td><input type="text" value="<%=news[2] %>" class="layui-input count" onblur="Update_News(this)"/></td>
          <td></td>
          <td><input type="checkbox" name="yyy" lay-skin="switch" lay-text="是|否" lay-filter="news" class="istop" <%=news[1]=="1"?"checked":"" %>></td>
        </tr>
        <tr column="quan">
          <td><input type="text" value="<%=quan[3] %>" class="layui-input name" onblur="Update_Quan(this)" disabled="disabled" /></td>
          <td><input type="text" value="<%=quan[0] %>" class="layui-input sort" onblur="Update_Quan(this)"/></td>
          <td><input type="text" value="<%=quan[2] %>" class="layui-input count" onblur="Update_Quan(this)"/></td>
          <td></td>
          <td><input type="checkbox" name="yyy" lay-skin="switch" lay-text="是|否" lay-filter="quan" class="istop" <%=quan[1]=="1"?"checked":"" %>></td>
        </tr>
        <tr column="active">
          <td><input type="text" value="<%=active[3] %>" class="layui-input name" onblur="Update_Active(this)"/></td>
          <td><input type="text" value="<%=active[0] %>" class="layui-input sort" onblur="Update_Active(this)"/></td>
          <td><input type="text" value="<%=active[2] %>" class="layui-input count" onblur="Update_Active(this)" disabled="disabled"/></td>
          <td></td>
          <td><input type="checkbox" name="yyy" lay-skin="switch" lay-text="是|否" lay-filter="active" class="istop" <%=active[1]=="1"?"checked":"" %>></td>
        </tr>
        <%foreach(TagsInfo tags in tagslist){ count++ ;%>
        <tr column="tags" tagsid="<%=tags.ID %>">
          <td><input type="text" value="<%=tags.Name %>" class="layui-input name" onblur="Update_ModuleTags(this)"/></td>
          <td><input type="text" value="<%=tags.ModuleSort %>" class="layui-input modulesort" onblur="Update_ModuleTags(this)"/></td>
          <td><input type="text" value="<%=tags.Count %>" class="layui-input count" onblur="Update_ModuleTags(this)"/></td>
          <td></td>
          <td><input type="checkbox" name="yyy" lay-skin="switch" lay-text="是|否" lay-filter="tagsistop" class="istop" <%=tags.ModuleIsTop==1?"checked":"" %>></td>
        </tr>
        <% } %>
        <%
            List<CategoryInfo> parentlist=categorylist.Where(x=>x.ParentID==0).ToList();
            foreach(CategoryInfo category in parentlist){ count++ ;%>
            <tr column="category" categoryid="<%=category.ID %>">
              <td><input type="text" value="<%=category.Name %>" class="layui-input name" onblur="Update_ModuleCategory(this)"/></td>
              <td><input type="text" value="<%=category.ModuleSort %>" class="layui-input modulesort" onblur="Update_ModuleCategory(this)"/></td>
              <td><input type="text" value="<%=category.Count %>" class="layui-input count" onblur="Update_ModuleCategory(this)"/></td>
              <td></td>
              <td><input type="checkbox" name="yyy" lay-skin="switch" lay-text="是|否" lay-filter="categoryistop" class="istop" <%=category.ModuleIsTop==1?"checked":"" %>></td>
            </tr>
            <%
            List<CategoryInfo> childlist=categorylist.Where(x=>x.ParentID==category.ID).ToList();
            foreach(CategoryInfo child in childlist){ count++ ;%>
            <tr column="category" categoryid="<%=child.ID %>">
              <td><input type="text" value="<%=child.Name %>" class="layui-input name" onblur="Update_ModuleCategory(this)"/></td>
              <td><input type="text" value="<%=child.ModuleSort %>" class="layui-input modulesort" onblur="Update_ModuleCategory(this)"/></td>
              <td><input type="text" value="<%=child.Count %>" class="layui-input count" onblur="Update_ModuleCategory(this)"/></td>
              <td></td>
              <td><input type="checkbox" name="yyy" lay-skin="switch" lay-text="是|否" lay-filter="categoryistop" class="istop" <%=child.ModuleIsTop==1?"checked":"" %>></td>
            </tr>
        <% }} %>
      </tbody>
    </table>
</form>
</div>
<script>

    layui.use(["form", "table", "laydate"], function () {
        var $ = layui.jquery, form = layui.form, laydate = layui.laydate;
        table = layui.table;
        form.on('switch(news)', function (data) {
            Update_News(this);
        });
        form.on('switch(quan)', function (data) {
            Update_Quan(this);
        });
        form.on('switch(active)', function (data) {
            Update_Active(this);
        });
        form.on('switch(tagsistop)', function (data) {
            Update_ModuleTags(this);
        });
        form.on('switch(categoryistop)', function (data) {
            Update_ModuleCategory(this);
        });
    });

    function Update_News(o) {
        var obj = $(o).parent().parent();
        var data = {};
        data.act = "Update_News";
        data.sort = obj.find(".sort").val();
        data.istop = obj.find(".istop").prop("checked") ? 1 : 0;
        data.name = obj.find(".name").val();
        data.count = obj.find(".count").val();
        data.sign = GetSign(data.act);
        if (data.name.indexOf("&") > -1) {
            LayerBox.Error("输入内容里不能包含&字符");
            return;
        }
        Ajax.Post("/tools/Admin.ashx", data, function (r) {});
    };
    function Update_Quan(o) {
        var obj = $(o).parent().parent();
        var data = {};
        data.act = "Update_Quan";
        data.sort = obj.find(".sort").val();
        data.istop = obj.find(".istop").prop("checked") ? 1 : 0;
        data.name = obj.find(".name").val();
        data.count = obj.find(".count").val();
        data.sign = GetSign(data.act);
        if (data.name.indexOf("&") > -1) {
            LayerBox.Error("输入内容里不能包含&字符");
            return;
        }
        Ajax.Post("/tools/Admin.ashx", data, function (r) { });
    };
    function Update_Active(o) {
        var obj = $(o).parent().parent();
        var data = {};
        data.act = "Update_Active";
        data.sort = obj.find(".sort").val();
        data.istop = obj.find(".istop").prop("checked") ? 1 : 0;
        data.name = obj.find(".name").val();
        data.count = obj.find(".count").val();
        data.sign = GetSign(data.act);
        if (data.name.indexOf("&") > -1) {
            LayerBox.Error("输入内容里不能包含&字符");
            return;
        }
        Ajax.Post("/tools/Admin.ashx", data, function (r) { });
    };

    function Update_ModuleTags(o) {
        var obj = $(o).parent().parent();
        var data = {};
        data.act = "Update_ModuleTags";
        data.count = obj.find(".count").val();
        data.modulesort = obj.find(".modulesort").val();
        data.moduleistop = obj.find(".istop").prop("checked") ? 1 : 0;
        data.name = obj.find(".name").val();
        data.tagsid = obj.attr("tagsid");
        data.sign = GetSign(data.act);
        if (data.name.indexOf("&") > -1) {
            LayerBox.Error("输入内容里不能包含&字符");
            return;
        }
        Ajax.Post("/tools/Admin.ashx", data, function (r) { });
    };

    function Update_ModuleCategory(o) {
        var obj = $(o).parent().parent();
        var data = {};
        data.act = "Update_ModuleCategory";
        data.categoryid = obj.attr("categoryid");
        data.count = obj.find(".count").val();
        data.modulesort = obj.find(".modulesort").val();
        data.moduleistop = obj.find(".istop").prop("checked") ? 1 : 0;
        data.name = obj.find(".name").val();
        data.sign = GetSign(data.act);
        if (data.name.indexOf("&") > -1) {
            LayerBox.Error("输入内容里不能包含&字符");
            return;
        }
        Ajax.Post("/tools/Admin.ashx", data, function (r) { });
    };

</script>
</body>
</html>
